#!/bin/bash 

MY_PWD=$(pwd)

BUFF=`cat CFG_INSTALL |grep SOFT_INSTALL_PATH`
INSTALL_PATH=${BUFF#*=}  # 获取用户配置的软件安装路径
# echo $INSTALL_PATH

if [ -d $INSTALL_PATH ]
then
	read -p "${INSTALL_PATH} 已经存在 是否清空[Y/n]?" CHOOSE
	if [ $CHOOSE == "Y" ]
	then
		rm -r $INSTALL_PATH
	else
		echo "脚本退出"
		exit
	fi
fi
mkdir $INSTALL_PATH

cd src
make
make clean

cd $MY_PWD

tar -zcf temp.tar.gz bin log lib cfg
mv temp.tar.gz $INSTALL_PATH

cd $INSTALL_PATH
tar -zxf temp.tar.gz

DATA_TIME=`date`
echo "# NAME_FIND  $DATA_TIME" >> ~/.bashrc 
echo "export NAME_FIND_HOME=$INSTALL_PATH" >> ~/.bashrc 
echo 'export PATH=$PATH:'"$INSTALL_PATH/bin" >> ~/.bashrc
source ~/.bashrc
rm temp.tar.gz
